<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>登陆</title>
		<link rel="stylesheet" href="../css/logon.css">
	</head>
	<body>
		
		<div class="main-box">
			<h3 align="center">登陆您的账号</h3>
			<p class="tip">没有账号?<span class="login-bt"><a href="Login.html">立即注册</a>
			</span>
			</p>
			<div class="form">
				
				<div class="row">
					<label>手机号</label>
					<form name="logon" action="../index.html">
					<input type="tel" class="inp" name="uname" maxlength=11 id="mobile" oninput="checkMobile">
					
					<div class="warm" id="mobileTip"></div>
				</div>
				
				<div class="row">
					<label>密码</label>
					<input type="password" class="inx" maxlength=11 id="password" oninput="checkPassword">
					<div class="warm" id="passwordTip"></div>
				</div>
				
				<div class="foot">
						<input type="checkbox">记住密码<p class="forget">忘记密码？<a href="forget.html">立即找回</a></p>	
				</div>
				
					<div class="sub" id="sub" onclick="regF()">登陆</div>
					<!-- <input type="submit"  value="denglu"> -->
				<div class="foot1">
					<input type="checkbox" checked>
					阅读并接受<a href="URP.html">用户服务协议及隐私政策</a>
				</div>
				</form>
			</div>
			
		</div>
		
		<script>
			let flag=false;
			let sec=60;
			//手机号
			function checkMobile(){
				let mobileDom=document.getElementById("mobile");
				let mobile =mobileDom.value;
				let  mobileTip=document.getElementById("mobileTip");
				if(!mobile){
					mobileDom.style.borderColor="red";
					mobileTip.innerText="请输入手机号";
					return false;
					}
				let myReg=/^[1][3-9][0-9]{9}$/;
				 if (!myReg.test(mobile)) {
					mobileDom.style.borderColor="red";
					mobileTip.innerText="手机号格式错误";	
					return false;
					}else{
					mobileDom.style.borderColor="#E0E0E0";
					mobile.innerText="";
					return true;
					}
			}
			//密码
			function checkPassword(){
				let passwordDom=document.getElementById("password");
				let password =passwordDom.value;
				let passwordTip=document.getElementById("passwordTip");
				if(!password){
					passwordDom.style.borderColor="red";
					passwordTip.innerText="请输入密码";
					return false;
				}
				else{
					passwordDom.style.borderColor="#E0E0E0";
					let sub=document.getElementById("sub");
					sub.style.background="#2E58FF";
					passwordTip.innerText="";
					return true;
				}
			}
			
			//校验结果
			function checkResult(){
				let ifMobile=checkMobile();
				if (!ifMobile) {
					return;
				}
				if(checkMobile()&&checkPassword()){
					
					return true;
				}
			}
			//登陆
			function regF(){
				if (checkMobile()&&checkPassword()&&checkResult()) {
					alert("登陆成功！");
					setTimeout("document.logon.submit()",0);
					//window.location.href='../index.html';
				}
			}
		</script>
	</body>
</html>